package main

import (
	"fmt"
	"github.com/xyctruth/stream"
)

func main() {

	// constraints.Ordered
	s := stream.NewSliceByOrdered([]string{"d", "a", "b", "c", "a"}).
		Filter(func(s string) bool { return s != "b" }).
		Map(func(s string) string { return "class_" + s }).
		Sort().
		Distinct().
		ToSlice()
	fmt.Println(s)

	students := []Student{{"zhangsan", 1}, {"lisi", 2}, {"wangwu", 3}}
	slice := stream.
		NewSliceByMapping[Student, string, any](students).
		Map(func(student Student) string { return student.Name }).
		ToSlice()
	fmt.Println(slice)

}

type Student struct {
	Name string `json:"name"`
	Age  int    `json:"age"`
}
